package com.wang.web3.adapter;

import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wang.web3.R;
import com.wang.web3.bean.KittyInfoBean;
import com.wang.web3.bean.TianWallet;

import java.util.List;

/**
 * @author Mr.Wang
 * @version v0.3.2
 * @time 2017/7/12
 * @describe
 */

public class WalletAdapter extends BaseQuickAdapter<TianWallet, BaseViewHolder> {

    LinearLayout rootView;
    TextView walletName,walletAdress,walletInfo;

    PersonHolderListener personHolderListener;


    public WalletAdapter(List<TianWallet> commentInfoBeen, PersonHolderListener personHolderListener) {
        super(R.layout.wallet_item_layout, commentInfoBeen);
        this.personHolderListener = personHolderListener;
    }

    @Override
    protected void convert(final BaseViewHolder helper, TianWallet item) {

        rootView = helper.getView(R.id.rootView);
        walletName = helper.getView(R.id.walletName);
        walletAdress = helper.getView(R.id.walletAdress);
        walletInfo = helper.getView(R.id.walletInfo);
        helper.setText(R.id.walletName,"账户:"+ item.getName());
        helper.setText(R.id.walletAdress,"地址:" + item.getAdress());
        helper.setText(R.id.walletInfo,item.getInfo());


        rootView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    personHolderListener.onPersonItemClicked(v, event, helper.getAdapterPosition());
                }
                return false;
            }
        });
    }


    public interface PersonHolderListener<T> {

//        void onPersonItemClicked(View v, MotionEvent event, int position);

        void onPersonItemClicked(View v, MotionEvent event, int position);
    }

}
